﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using KLY.DataModels;
using KLY.Tools;

namespace KLY.ServiceCore
{
    public class SearchViplineInfo: ServiceBase<SearchLineRequest, SearchLineResponse>
    {
        public SearchViplineInfo(SearchLineRequest request)
        {
            this._request = request;
        }

        public override SearchLineResponse Process()
        {
            if (!Validate())
            {
                return new SearchLineResponse
                {
                    Ok = false
                };
            }
            base.Url = string.Format("http://{0}/v1/api/102010/", BizCommon.Domain);
            base.Method = HttpMethod.POST;
            base.ListHead = new List<RequestHead>
                {
                    new RequestHead
                    {
                        HeaderName="version",
                        HeaderValue="1.0.0"
                    }
                };
            if (this._request.page_size == 0)
                this._request.page_size = BizCommon.PagedListMaxRecord;
            if (this._request.page_no == 0)
                this._request.page_no = 1;

            base.Request = this._request;
            return base.Process();
        }

        private bool Validate()
        {
            if (this._request.start_area == "-1" || this._request.end_area == "-1")
            {
                return false;
            }
            return true;
        }

        private SearchLineRequest _request;
    }
}
